#version 460
#extension GL_GOOGLE_include_directive : enable

#include "../../../core/shader_tranform.h"
#include "../../../core/shader_widget_panel.h"
#include "../../../core/shader_widget_color.h"
#include "../../../core/shader_color.h"


layout(points) in;
layout(points, max_vertices=1) out;



//纹理数组 纹理Z坐标
//layout(std430, binding = DEF_BINDING_WIDGET_IcoCoord) readonly buffer U4_Matrix {
//	uint m_InstanceCoord[];
//};




in gl_PerVertex {
	vec4	gl_Position;
	float	gl_PointSize;
} gl_in[];

layout(location = 1) in VS_GS_VERTEX {
	uint InstanceIndex;
}vertex_in[];




layout(location = 1) out VS_FS_VERTEX {
	vec4		gColor;
	flat float	gCoordInstance;
};

out gl_PerVertex {
	vec4	gl_Position;
	float	gl_PointSize;
};



void main(void){
	// 位置  大小  对齐方式  深度
	mat3x2 mat = m_LP_SD[vertex_in[0].InstanceIndex];
	
	vec4 v = vec4(0.0, 0.0, mat[2].y, 1.0);
	
	v.x = min(mat[1].x, mat[1].y);
	v.y = v.x;

	gl_PointSize = v.x - vertNum*2;
	v.xy *= 0.5f;
	gl_PointSize *= m_Scale.x;
	
	gl_Position = v;
	gl_Position.xy += mat[0];
	gl_Position.xy *= m_Scale;
	gl_Position.xy += m_Loc;

	//gl_Position = vec4(100, 200, 0, 1.0);
	gl_Position = mat_ProjecView * gl_Position;

	
	//gCoordInstance = m_InstanceCoord[vertex_in[0].InstanceIndex];
	gCoordInstance = mat[2].x;

	gColor = f_glsl_buildColor(InstanceColor[vertex_in[0].InstanceIndex]);
	//vColor = InstanceColor[vertex_in[0].InstanceIndex];
	EmitVertex();
	EndPrimitive();
	
}



 